///流媒体服务相关头文件
#include "StreamManager.h"
#include "ControlManager.h"
#include "x_loadso.h"
#include "x_include.h"

bool bRun = true;

///流媒体服务相关定义
CStreamManager streamManager;
CControlManager controlManager;

void OnSignal(int nSigNum)
{
	if (nSigNum == SIGINT)
	{
		J_OS::LOGINFO("Quit NvrServer");
		bRun = false;
	}
};

int main(int argc,char **argv)
{
    CXLoadso loadSo;
    ///加载模块
    if (loadSo.JoLoadSo() != J_OK)
    {
        J_OS::LOGINFO("main loadSo JoLoadSo error");
        return 0;
    }

	///流媒体服务相关
	if (streamManager.StartService(CXConfig::GetStreamServerPort()) < 0)
	{
		J_OS::LOGINFO("main streamManager Start service error, port = %d", CXConfig::GetStreamServerPort());
		return 0;
	}

	///管理服务器相关
	if (controlManager.StartService(CXConfig::GetHttpServerPort()) < 0)
	{
		J_OS::LOGINFO("main controlManager Start service error, port = %d", CXConfig::GetHttpServerPort());
		return 0;
	}

    signal(SIGINT, OnSignal);
	while(bRun)
	{
		usleep(10000);
	}

	streamManager.StopService();
	controlManager.StopService();
	loadSo.JoUnloadSo();

	return 0;
}


